<!--管理员添加学生实习记录-->
<style type="text/css">
	h3 {
		padding-bottom: 20px;
	}
	
	.input-group {
		/* font-size: 14px; */
		margin-bottom: 25px;
	}
	
	button {
		float: right;
		margin-left: 20px;
	}
	
	#gongsi2 {
		width: 60%;
		height: 30px;
	}
	
	.demo-input {
		padding-left: 10px;
		height: 38px;
		min-width: 262px;
		line-height: 38px;
		border: 1px solid #e6e6e6;
		background-color: #fff;
		border-radius: 2px;
	}
	
	#submit1 {
		position: fixed;
	}
	
	#shibai {
		position: fixed;
	}
</style>

<div class="modal-dialog modal fade" id="submit1">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>提交成功！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>
<div class="modal-dialog modal fade" id="shangchuan">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>上传成功！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>
<div class="modal-dialog modal fade" id="shibai">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>提交失败！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>
<div class="modal-dialog modal fade" id="shangchuan1">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>上传失败！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>

<h3 class="text-center">添加实习记录</h3>
<div class="input-group margintop">
	<span class="input-group-addon">公司</span>
	<select id="gongsi2">

	</select>
</div>
<div class="input-group margintop">
	<span class="input-group-addon" id="">实习岗位</span>
	<input type="text" id="job" class="form-control" placeholder="请输入实习岗位" aria-describedby="sizing-addon1">
</div>
<div class="input-group margintop">
	<span class="input-group-addon" id="">学生学号</span>
	<input type="text" id="job_sno" class="form-control" placeholder="请输入学生学号" aria-describedby="sizing-addon1">
</div>
<div class="input-group margintop">
	<span class="input-group-addon" id="">工作单位名称</span>
	<input type="text" id="unitName" class="form-control" placeholder="请输入工作单位名称" aria-describedby="sizing-addon1">
</div>
<div class="input-group margintop">
	<span class="input-group-addon" id="">工作单位地址</span>
	<input type="text" id="unitAddress" class="form-control" placeholder="请输入工作单位地址" aria-describedby="sizing-addon1">
</div>
<div class="input-group margintop">
	<span class="input-group-addon" id="">实习开始时间</span>
	<input type="text" class="demo-input" id="sx_start" placeholder="请选择日期" />
</div>
<div class="input-group margintop">
	<span class="input-group-addon" id="">实习结束时间</span>
	<input type="text" class="demo-input" id="sx_end" placeholder="请选择日期" />
</div>

<button type="button" class="btn btn-primary" id="submit_a">提交记录</button>
<button type="button" class="btn btn-primary" id="submit_b">批量导入实习记录</button>

<script>
	$('#submit1').on('hidden.bs.modal', function() {
		$('.center').html('');
		$('.center').load('./tianjiashixijilu.html');
	})

	//初始化日期编辑器
	laydate.render({
		elem: '#sx_start',
		type: 'datetime'
	});
	laydate.render({
		elem: '#sx_end',
		type: 'datetime'
	});

	$.ajax({
		xhrFields: {
			withCredentials: true
		},
		type: 'GET',
		url: getFullURL("get-companys"),
		data: {},
		dataType: 'json',
		success: function(data) {
			if(data.status == 0) {
				console.log(data);
				$.each(data.list, function(i, n) {
					var str = `
						<option value="` + n.cid + `">` + n.cyName + `</option>
					`;

					$('#gongsi2').append(str);
				})
			}
		},
		error: function(err) {
			alert("请求异常，请重新登录！", function() {
				$(location).attr('href', './login.html');
			})
		}
	})

	$('#submit_a').click(function() {
		$.ajax({
			xhrFields: {
				withCredentials: true
			},
			type: 'POST',
			url: getFullURL("admin/add-intern"),
			data: {
				sno: $('#job_sno').val(),
				cid: $('#gongsi2').val(),
				job: $('#job').val(),
				unitName: $('#unitName').val(),
				unitAddress: $('#unitAddress').val(),
				entryDate: $('#sx_start').val(),
				endDate: $('#sx_end').val()
			},
			dataType: 'json',
			success: function(data) {
				if(data.status == 0) {
					$('#submit1').modal({
						keyboard: true,
						show: true
					})
				} else if(data.status == -1) {
					$('#shibai').modal({
						keyboard: true,
						show: true
					})
				}
			},
			error: function(err) {
				alert("请求异常，请重新登录！", function() {
					$(location).attr('href', './login.html');
				})
			}
		})
	})
</script>